import request from "./http";

// http://floor.huluxia.com/post/list/ANDROID/4.1.8
// _key=79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E
// &start=0
// &count=20
// &cat_id=96
// &tag_id=0
// &sort_by=0
export function getPostData(params) {
    // if (!params.start) params.start = 0;
    // if (!params.count) params.count = 20;
    // if (!params.tag_id) params.tag_id = 0;
    // if (!params.sort_by) params.sort_by = 0;
    // if (!params._key) params._key = "79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E";
    // params.start = 0;
    // params.count = 20;
    // params.sort_by = 0;
    // params.tag_id = 0;
    // params._key = "79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E";
    return request({
        url: "/post/list/ANDROID/4.1.8",
        method: "post",
        params,
    })
}

export function getPostJson() {
    return request({
        url: "./json/post.json",
        method: "get",
    })
}

export function getPostDetailJson() {
    return request({
        url: "./json/postDetail.json",
        method: "get",
    })
}

// 从二页开始的评论
export function getPostCommentJson() {
    return request({
        url: "./json/postComment.json",
        method: "get",
    })
}

// !获取喜欢 可用但是不用
// 获取喜欢
// http://floor.huluxia.com/post/favorite/check/ANDROID/2.0
// _key=79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E
// &post_id=51510185
// export function getPostFavorite(params) {
//     params._key = "79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E";
//     return request({
//         url: "/post/favorite/check/ANDROID/2.0",
//         method: "get",
//         params,
//     })
// }

// 获取点赞
// http://floor.huluxia.com/post/praise/check/ANDROID/2.1
// _key=79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E
// &post_id=51510185
export function getPostPraise(params) {
    params._key = "79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E";
    return request({
        url: "/post/praise/check/ANDROID/2.1",
        method: "get",
        params,
    })
}

// !设置喜欢 不可用
// {"msg":"","groupTitle":"默认收藏夹","more":0,"start":"","status":1}
export function createPostFavorite(params) {
    params._key = "79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E";
    return request({
        url: "/post/favorite/create/ANDROID/4.1.8",
        method: "get",
        params,
    })
}

// !取消设置喜欢 不可用
// {"msg":"","status":1}
export function destroyPostFavorite(params) {
    params._key = "79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E";
    return request({
        url: "/post/favorite/destroy/ANDROID/4.1.8",
        method: "get",
        params,
    })
}

// 切换点赞
// _key=79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E
// {"msg":"","praise":1,"status":1}
// {"msg":"","praise":2,"status":1}
// 2 是点赞 
// 1 是不点赞
// &post_id
export function TogglePostPraise(params) {
    params._key = "79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E";
    return request({
        url: "/post/praise/ANDROID/2.1",
        method: "get",
        params,
    })
}


// http://floor.huluxia.com
// /post/search/ANDROID/4.1.8
// ?_key=79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E
// &device_code=666
// &start=0
// &count=20
// &cat_id=96
// &keyword=123
// &flag=1

export function getSearchPostList(params) {
    params._key = "79C01CEFACD51FFB4A622C86863C3E9D7E4BFE77FBFAD2C9B4B8F17A3ED35CFFF6AE76F07CAE7686706DD0D11037083834712141F2272A2E";
    params.device_code = "device_code";
    return request({
        url: "/post/search/ANDROID/4.1.8",
        method: "get",
        params,
    })
}
